import type {
  AddMaijiaCarRes,
  AddOrderDataReq,
  AddOrderDataRes,
  AddPiciZhichuDataReq,
  AddPiciZhichuDataRes,
  DataCarGoodsRes,
  DeleteCarRes,
  GetGoodsListReq,
  GetGoodsListRes,
  GetMaijiaCarqudanReq,
  GetMaijiaCarqudanRes,
  GetMaijiaCarRes,
  GetOrderDataReq,
  GetOrderDataRes,
  GetSelfCategoryGoodsReq,
  GetSelfCategoryGoodsRes,
  GuadanDataRes,
  HuankuanDataReq,
  HuankuanDataRes,
} from './types';
/**
 * 订单相关接口
 */
import { get, post } from '@/utils/request';

/** 获取买家存单 */
export const getMaijiaCarqudan = (params?: GetMaijiaCarqudanReq) =>
  get<GetMaijiaCarqudanRes>('/syapi/order/getMaijiaCarqudan', { params });

/** 结算syapi/order/addOrderData */
export const addOrderData = (params?: AddOrderDataReq) =>
  post<AddOrderDataRes>('/syapi/order/addOrderData', {
    data: params,
    header: {
      'Content-Type': 'application/json',
    },
  });

export const dataCar = (params?: { car_id: number; maijia_id: number }) =>
  post<DataCarGoodsRes>('/syapi/order/dataCar', { params });

export const getMaijiaCar = (params?: any) => post<GetMaijiaCarRes>('/syapi/order/getMaijiaCar', { params });
export const deleteCar = (params?: { car_id: number; order_car_id: number | string }) => post<DeleteCarRes>('/syapi/order/deleteCar', { params });

export const guadanData = (params?: { car_id: number }) => post<GuadanDataRes>('/syapi/order/guadanData', { params });
export const addMaijiaCar = (params?: { car_id: number; maijia_id: string; name: string; exchangemaijiatype: string }) =>
  post<AddMaijiaCarRes>('/syapi/order/addMaijiaCar', { params });
export const guadantocar = (params?: { car_id?: number; car_ids?: number[] }) => post<GuadanDataRes>('/syapi/order/guadantocar', {
  data: params,
  header: {
    'Content-Type': 'application/json',
  },
});
export const getOrderData = (data?: GetOrderDataReq) => post<GetOrderDataRes>('/syapi/order/getOrderData', { data });

export const huankuanData = (data?: HuankuanDataReq) => post<HuankuanDataRes>('/syapi/order/huankuanData', {
  data,
  header: {
    'Content-Type': 'application/json',
  },
});
// syapi/config/receiptField
export const receiptField = () =>
  get<any>('/syapi/config/receiptField');
export const getAllPiciData = (data: { status: number }) =>
  post<any>('/syapi/Pici/getAllPiciData', { data });

export const getOrderDetailData = (data: { order_id: number; piao_num: string }) =>
  post<any>('/syapi/order/getOrderDetailData', { data });
export const updateOrderData = (data: { id: number }) =>
  post<any>('/syapi/order/updateOrderData', { data });
export const zuofeiOrderData = (data: { id: number; zuofei: number }) =>
  post<any>('/syapi/order/zuofeiOrderData', { data });
export const goodsLists = (data: GetGoodsListReq) =>
  post<GetGoodsListRes>('/syapi/goods/goodslists', { data });
export const addPiciZhichuData = (data: AddPiciZhichuDataReq) =>
  post<AddPiciZhichuDataRes>('/syapi/Statistics/addPiciZhichuData', { data });

export const delFeiyongxiangData = (data: { id: number }) =>
  post<any>('/syapi/Statistics/delFeiyongxiangData', { data });
export const updatePiciData = (data: { id: number; status: number }) =>
  post<any>('/syapi/Pici/updatePiciData', { data });

export const getSelfCategoryGoods = (data: GetSelfCategoryGoodsReq) =>
  post<GetSelfCategoryGoodsRes>('/syapi/goods/getSelfCategoryGoods', { data });
export const updateStatus = (data: { ids: number; status: number }) =>
  post<any>('/syapi/goods/updateStatus', { data });

export const updateSelfStatus = (data: { status: number; editShangpinId: number[] }) =>
  post<any>('/syapi/goods/updateSelfStatus', { data });

// /syapi/goods/edcategory - 批量更改分类
export const edcategory = (data: { goods_ids: number[]; cate_id: number; cate_id2: number }) =>
  post<any>('/syapi/goods/edcategory', { data });

// /syapi/goods/delGoods
export const delGoods = (data: { id: number }) =>
  post<any>('/syapi/goods/delGoods', { data });

// exportGoodsData
export const exportGoodsData = (data: {
  huozhu_name: string;
  pici: number;
  pici_id: number;
  new_pici_status: boolean;
  goods_id: number[];
  huozhu_id: string;
  license: string;
  new_pici: string;
}) =>
  post<any>('/syapi/goods/exportGoodsData', { data });

// /syapi/goods/addSelf 新增货品
export const addSelf = (data: any) =>
  post<any>('/syapi/goods/addSelf', { data });

// /syapi/batch/formatData
export const formatData = (data: { maijia_id: number; bitchItems: string }) =>
  post<any>('/syapi/batch/formatData', { data });

export const kaidanDataCar = (data: any) =>
  post<any>('/syapi/order/kaidanDataCar', { data });
